package com.springboot.demo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.springboot.demo.entity.validate.device.DevClusterDescGroup;
import com.springboot.demo.entity.validate.device.DevClusterNameGroup;
import com.springboot.demo.entity.validate.user.IdGroup;
import com.springboot.demo.entity.validate.user.UsernameGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * @author wubc683
 * @desc
 * @date 2021-07-26 14:20
 */
@Data
public class DeviceCluster {
    @ApiModelProperty(value = "设备群id", required = true)
    @NotNull(message = "设备id不能为null", groups = IdGroup.class)
    private Long id;
    @NotBlank(message = "设备群名不能为null或空", groups = DevClusterNameGroup.class)
    @Length(min = 1, max = 15, message = "设备群名长度不对", groups = DevClusterNameGroup.class)
    @Pattern(regexp = "^[a-zA-Z0-9_-]{1,15}$", message = "设备群名格式错误",
            groups = DeviceCluster.class)
    @ApiModelProperty(value = "设备群名,`a-zA-Z0-9_-,1~15位", required = true)
    private String name;
    @ApiModelProperty(value = "设备群描述,不超过96")
    @Length(max = 96, message = "设备群描述太长", groups = DevClusterDescGroup.class)
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    private Date createDate;
    @ApiModelProperty("用户在设备群中的角色")
    private Integer role;
}
